﻿using ICSharpCode.WinFormsUI.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevelopAssistant.GuiTest
{
    public partial class Form2 : Form
    {
        private ColumnModel columnModel;
        private TableModel tableModel;

        public Form2()
        {
            InitializeComponent();
            InitializeDataTable();
        }

        private void InitializeDataTable()
        {
            this.columnModel = new ColumnModel();
            this.tableModel = new TableModel();

            // 
            // table
            // 
            this.nDataTable1.BackColor = System.Drawing.Color.White;
            this.nDataTable1.ColumnModel = this.columnModel;
            this.nDataTable1.EnableHeaderContextMenu = false;
            this.nDataTable1.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 9.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.nDataTable1.Location = new System.Drawing.Point(24, 24);
           
            this.nDataTable1.TabIndex = 0;
            this.nDataTable1.TableModel = this.tableModel;
             
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            this.nDataTable1.BeginUpdate();

            TextColumn textColumn = new TextColumn();
            textColumn.Editable = true;
            textColumn.Sortable = true;
            textColumn.Width = 200;
            textColumn.Text = "Text";

            CheckBoxColumn checkBoxColumn = new CheckBoxColumn();
            checkBoxColumn.Sortable = false;
            checkBoxColumn.Text = "CheckBox";
            checkBoxColumn.Width = 494;

            DateTimeColumn dateTimeColumn = new DateTimeColumn();
            dateTimeColumn.DateTimeFormat = System.Windows.Forms.DateTimePickerFormat.Short;
            dateTimeColumn.Editable = false;
            dateTimeColumn.ShowDropDownButton = false;
            dateTimeColumn.Sortable = false;
            dateTimeColumn.Text = "DateTime";

            DateTimeColumn describColumn = new DateTimeColumn();
            describColumn.Sortable = false;
            dateTimeColumn.Editable = false;
            describColumn.Text = "Describ";

            this.columnModel.Columns.AddRange(new Column[] { textColumn, checkBoxColumn, dateTimeColumn, describColumn });

            //this.nDataTable1.TableModel.Rows.AddRange(new Row[] { new Row(new Cell[] {new Cell("Item 1"),
            //                                                                    new Cell("CheckBox 1"),
            //                                                                    new Cell(new DateTime(2005, 7, 19, 11, 49, 1, 0))}),
            //                                                new Row(new Cell[] {new Cell("Item 2"),
            //                                                                    new Cell("CheckBox 2"),
            //                                                                    new Cell(new DateTime(2005, 7, 20, 11, 49, 1, 0))}),
            //                                                new Row(new Cell[] {new Cell("Item 3"),
            //                                                                    new Cell("CheckBox 3"),
            //                                                                    new Cell(new DateTime(2005, 7, 21, 11, 49, 1, 0))}),
            //                                                new Row(new Cell[] {new Cell("Item 4"),
            //                                                                    new Cell("CheckBox 4"),
            //                                                                    new Cell(new DateTime(2005, 7, 22, 11, 49, 1, 0))}),
            //                                                 new Row(new Cell[] {new Cell("Item 4"),
            //                                                                    new Cell("CheckBox 4"),
            //                                                                    new Cell(new DateTime(2005, 7, 22, 11, 49, 1, 0))}),
            //                                                  new Row(new Cell[] {new Cell("Item 4"),
            //                                                                    new Cell("CheckBox 4"),
            //                                                                    new Cell(new DateTime(2005, 7, 22, 11, 49, 1, 0))}),
            //                                                   new Row(new Cell[] {new Cell("Item 4"),
            //                                                                    new Cell("CheckBox 4"),
            //                                                                    new Cell(new DateTime(2005, 7, 22, 11, 49, 1, 0))}),
            //                                                new Row(new Cell[] {new Cell("Item 5"),
            //                                                                    new Cell("CheckBox 5"),
            //                                                                    new Cell(new DateTime(2005, 7, 23, 11, 49, 1, 0))})});

            for(int i = 1; i < 60; i++)
            {
                var row2 = new Row(
                    new Cell[] {new Cell("Item "+i+""),
                                new Cell("CheckBox "+i+""),
                                new Cell(new DateTime(2005, 7, 20, 11, 49, 1, 0)),
                                new Cell("CheckBox "+i+"")
                    }); 

                this.nDataTable1.TableModel.Rows.Add(row2);
            }


            this.nDataTable1.EndUpdate();
        }
    }
}
